home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
(A)Z
/
(A)Z11.ADF
/
LOGO
/
LOGOSOURCE
/
splithelp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-07-01
|
1KB
|
68 lines
/*
* splithelp.c -- turn nroff output of logoman into help files.
*/
extern char *index();
#define SPACES " "
#include <stdio.h>
main(argc,argv)
char **argv;
{
FILE *ip, *op;
int writing = 0; /* nonzero when writing a file */
int empty = 0; /* nonzero after an empty line */
register char *cp;
char line[100];
char primitive[50];
if ((ip = fopen(argv[1],"r")) == NULL) {
printf("Splithelp: Can't read input.\n");
exit(1);
}
while (fgets(line,100,ip)) {
cp = index(line, '-');
if (cp && *(cp - 1) == ' ' && *(cp + 1) == ' ') {
empty = 0;
if (writing)
fclose(op);
sscanf(line,"%s",primitive);
if ((op = fopen(primitive,"w")) == NULL) {
printf("Splithelp: Can't write output <%s>.\n", primitive);
exit(1);
}
fprintf(op,"%s",line);
writing++;
} else if (line[0] == '\n' || strncmp(line,SPACES,16) == 0) {
empty++;
} else if (writing && line[0]==' ') {
sscanf(line,"%s",primitive);
if (empty && (index(primitive, '_') ||
primitive[strlen(primitive)-1] == '.')) {
fclose(op);
writing = 0;
}
else {
if (empty)
fprintf(op,"\n");
empty = 0;
fprintf(op,"%s",line);
}
} else if (writing) {
fclose(op);
writing = 0;
}
}
if (writing) fclose(op);
}